package com.weng.coder.service.convertor.impl.command;

import com.weng.coder.service.convertor.ConvertCommand;
import com.weng.coder.service.convertor.impl.ConvertedFile;

/**
 * 转换Spring配置
 * 
 * @author work
 */
public class SpringCommand implements ConvertCommand {

    @Override
    public void process(ConvertedFile file, String target, String name) {
        if (file.getFromName().equals("servlet-context.xml")) {
            file.replace("<context:component-scan base-package=\"cn.com.bmsoft.base\" use-default-filters=\"true\" />",
                    "<context:component-scan base-package=\"cn.com.bmsoft.base\" use-default-filters=\"true\" />\n    <context:component-scan base-package=\"cn.com.bmsoft." + target + "\" use-default-filters=\"true\" />");
            file.replace("<property name=\"typeAliasesPackage\" value=\"cn.com.bmsoft.base.domain\" />",
                    "<property name=\"typeAliasesPackage\" value=\"cn.com.bmsoft." + target + ".domain\" />");
            file.replace("<prop key=\"title\">基础架构系统</prop>", "<prop key=\"title\">" + name + "</prop>");
        }
    }
}
